package com.boot.util;

import java.util.concurrent.TimeUnit;

/**
 * @author MShaoJie
 * @create 2021/8/18 15:56
 **/
public class TimeUtil {

    private static volatile long currenTimeMillis;

    static {
        currenTimeMillis = System.currentTimeMillis();
        Thread daemon = new Thread(() -> {
            currenTimeMillis = System.currentTimeMillis();
            try {
                TimeUnit.MILLISECONDS.sleep(1);
            } catch (InterruptedException e) {
            }
        });
        daemon.setDaemon(true);
        daemon.setName("time-tick-thread");
        daemon.start();
    }

    public static long currenTimeMillis() {
        return currenTimeMillis;
    }
}
